package cn.ytian.scashier;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class ReadProduct implements ProductFileReader {
     static List<Product> readProduct(File file, String type) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file), "GBK"));
        String s = null;
        Product pr;
        List<Product> lp = new ArrayList<>();;
        while((s = br.readLine())!=null){//使用readLine方法，一次读一行
            String[] sl = s.split(type);
            pr = new Product(sl[0],sl[1],sl[2]);
            lp.add(pr);
        }

        br.close();
        return lp;
    }
}
